import java.util.concurrent.CountDownLatch;

/**
 * @author Jiange
 * @create 2021-05-13-13:50
 */
public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch downLatch = new CountDownLatch(6);

        for (int i = 0; i < 6; i++) {
            int finalI = i;
            new Thread(()->{
                System.out.println(Thread.currentThread().getName()+"\t"+ finalI);
                downLatch.countDown();
            },String.valueOf(i)).start();
        }
        downLatch.await();
        System.out.println("main--------");
    }
    public static void closeDoor(){
        for (int i = 0; i < 6; i++) {
            int finalI = i;
            new Thread(()->{
                System.out.println(Thread.currentThread().getName()+"\t"+ finalI);
            },String.valueOf(i)).start();
        }
    }
}
